# -*- Mode: Python -*- vi:si:et:sw=4:sts=4:ts=4:syntax=python

class Recipe(recipe.Recipe):
    name = 'sbc'
    version = '1.3'
    stype = SourceType.TARBALL
    url = 'https://www.kernel.org/pub/linux/bluetooth/sbc-%(version)s.tar.gz'
    tarball_checksum = '4a358581fb57b98e0c1c34606a35343f31f908f57c26659e51495f75e283785d'
    licenses = [License.LGPLv2_1Plus]
    files_libs = ['libsbc']
    files_devel = ['include/sbc/sbc.h', 'lib/pkgconfig/sbc.pc']
    configure_options = '--disable-tester --disable-tools'
    patches = ['sbc/0001-sbc-Use-stdint.h.patch',
               'sbc/0002-Don-t-use-NEON-with-aarch64-on-Clang.patch',
               'sbc/0003-sbc.h-Define-ssize_t-when-building-with-MSVC.patch',]
    autoreconf = True

    async def compile(self):
        if self.config.target_platform != Platform.LINUX:
            # Don't use --version-script on platforms other than GNU/Linux.
            # ld does not support that on non-GNU platforms. This is not done
            # via a patch to Makefile.am because the Autotools build system
            # doesn't regenerate after the Autofoo sources are changed.
            shell.replace(os.path.join(self.build_dir, 'Makefile'),
                          {'-Wl,--version-script=$(top_srcdir)/sbc/sbc.sym': '$(NULL)'})
        await super(Recipe, self).compile()
